﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <title>Login</title>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js"></script>
    <link rel="stylesheet" href="~/Content/css/login.css" />
</head>
<body>
    <div class="second_body">
        <div class="logo" style="font-size: 34px;padding-top: 34px;">胸痛中心<br><br>信息系统</div>
        <div class="title-zh"></div>
        <div class="title-en"></div>
        <div class="message" id="errmsg"></div>
        <table border="0" style="width:300px;">
            <tr>
                <td style="padding-bottom: 5px;width:55px;">用户名：</td>
                <td colspan="2"><input type="text" value="" id="txtName" class="login" maxlength="20" onkeypress="EnterPress(event)" /></td>
            </tr>
            <tr>
                <td class="lable" style="vertical-align: middle">密&nbsp;&nbsp;&nbsp;码：</td>
                <td colspan="2"><input type="password" value="" id="txtPwd" class="login" maxlength="20" onkeypress="EnterPress(event)" /></td>
            </tr>
            <tr style="display:none;">
                <td style="padding-bottom: 5px;width:55px;">验证码：</td>
                <td colspan="2">
                    <input type="text" style="width:70px;" value="" id="txtyzm" class="login" maxlength="5" onkeypress="EnterPress(event)" />
                    <img src="@Url.Action("CheckCode", "Login")" id="imgCode" alt="单击可刷新" onclick="ClickRemoveChangeCode()" />
                </td>
            </tr>
            <tr>
                <td colspan="3" style="text-align:center;padding-top:10px;">
                
                    <input type="button" value="重置" id="reset" class="reset_botton" />
                    <input type="submit" value="登录" id="login" class="login_button" />
                </td>
            </tr>
        </table>
    </div>
    <script type="text/javascript">
        function ClickRemoveChangeCode() {
            var code = $("#imgCode").attr("src");
            $("#imgCode").attr("src", code + "1");
        }
        function EnterPress(e) {
            var e = e || window.event;
            if (e.keyCode == 13) {
                $('#login').click();
            }
        }
        $("#login").click(function () {
            var userName = $("#txtName").val();
            var userPassword = $("#txtPwd").val();
            var yzm = $("#txtyzm").val();
            if (IsEmpty(userName)) {
                $("#errmsg").text("用户名不能为空");
                $("#txtName").focus();
                return;
            }
            if (IsEmpty(userPassword)) {
                $("#errmsg").text("密码不能为空");
                $("#txtPwd").focus();
                return;
            }
            //if (IsEmpty(yzm)) {
            //    $("#errmsg").text("验证码不能为空");
            //    $("#txtyzm").focus();
            //    return;
            //}
            var postData = {
                userName: userName,
                userPassword: userPassword,
                yzm: yzm
            };
            $.ajax({
                url: "/Login/DoAction",
                type: "GET",
                cache: false,
                async: true,
                data: postData,
                success: function (data) {
                    var result = $.parseJSON(data);
                    if (result.Result == 1) {
                        $("#errmsg").text("登录成功，请稍候...");
                        window.location.href = "/Home/Index";
                    }
                    else if (result.Result == 0) {
                        $("#errmsg").text(result.Body);
                        ClickRemoveChangeCode();
                    }
                    else {
                        $("#errmsg").text("程序错误");
                        ClickRemoveChangeCode();
                    }
                },
                error: function () {
                    $("#errmsg").text("程序错误");
                    ClickRemoveChangeCode();
                }
            });

        });
        $("#reset").click(function () {
            $("#txtName").val("");
            $("#txtPwd").val("");
            $("#txtyzm").val("");
            $("#errmsg").text("");
        });
    </script>
</body>
</html>